﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections;

namespace Musicman.Utilities.Configuration.Search
{
    public class SearchJobConfigurationCollection : ConfigurationElementCollection, IList
    {
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new SearchJobConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((SearchJobConfigurationElement)element).Name;
        }

        [ConfigurationProperty("maxworkingthreads", IsRequired = false, DefaultValue = 10)]
        public int MaxWorkingThreads
        {
            get { return (int)this["maxworkingthreads"]; }
            set { this["maxworkingthreads"] = value; }
        }

        #region IList Members

        public int Add(object value)
        {
            BaseAdd((SearchJobConfigurationElement)value);
            return this.Count - 1;
        }

        public void Clear()
        {
            BaseClear();
        }

        public bool Contains(object value)
        {
            throw new NotImplementedException();
        }

        public int IndexOf(object value)
        {
            return BaseIndexOf((ConfigurationElement)value);
        }

        public void Insert(int index, object value)
        {
            throw new NotImplementedException();
        }

        public bool IsFixedSize
        {
            get { return false; }
        }

        public new bool IsReadOnly
        {
            get { return false; }
        }

        public void Remove(object value)
        {
            throw new NotImplementedException();
        }

        public void RemoveAt(int index)
        {
            BaseRemoveAt(index);
        }

        public object this[int index]
        {
            get
            {
                return (SearchJobConfigurationElement)BaseGet(index);
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public object this[object key]
        {
            get
            {
                return (SearchJobConfigurationElement)BaseGet(key);
            }
            set
            {
                throw new NotImplementedException();
            }
        }
        #endregion

    }

    public enum SearchMode : byte
    {
        JobAtTheTime,
        JobsAtOnce
    }
}
